/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * temperatura.java
 *
 * Created on 26/10/2011, 13:29:31
 */
package br.com.fatecpg.tp1.formularios;

/**
 *
 * @author PC
 */
public class temperatura extends javax.swing.JInternalFrame {

    /** Creates new form temperatura */
    public temperatura() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jRadioButton5 = new javax.swing.JRadioButton();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);
        setTitle("Temperatura ");

        jLabel1.setFont(new java.awt.Font("Arial", 0, 14));
        jLabel1.setText("Quero converter:");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jLabel7.setText(".");

        jLabel8.setText(".");

        jLabel9.setText(".");

        jLabel10.setText(".");

        jLabel11.setText(".");

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setText("Celsius");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setText("Fahrenheit");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });

        buttonGroup1.add(jRadioButton3);
        jRadioButton3.setText("Kelvin");
        jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton3ActionPerformed(evt);
            }
        });

        buttonGroup1.add(jRadioButton4);
        jRadioButton4.setText("Rankine");
        jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton4ActionPerformed(evt);
            }
        });

        buttonGroup1.add(jRadioButton5);
        jRadioButton5.setText("Réaumur");
        jRadioButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jRadioButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButton5))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(112, 112, 112)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel1))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                            .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))
                        .addGap(169, 169, 169))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton1)
                    .addComponent(jRadioButton2)
                    .addComponent(jRadioButton3)
                    .addComponent(jRadioButton4)
                    .addComponent(jRadioButton5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        double celsiusFaren = ((Double.parseDouble(jTextField1.getText()))
                * 1.8 + 32);
        jLabel8.setText(celsiusFaren + " Fahrenheit");

        double celCel = ((Double.parseDouble(jTextField1.getText())));
        jLabel7.setText(celCel + " Celsius");

        double celReau = ((Double.parseDouble(jTextField1.getText()))
                * 0.8);
        jLabel10.setText(celReau + " Réaumur");

        double celRan = ((Double.parseDouble(jTextField1.getText()))
                + 273.15);
        jLabel11.setText(celRan * 1.8 + " Rankine");

        double celKel = ((Double.parseDouble(jTextField1.getText()))
                + 273.15);
        jLabel9.setText(celKel + " Kelvin");
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
        double celsiusFaren = ((Double.parseDouble(jTextField1.getText())));
        jLabel8.setText(celsiusFaren + " Fahrenheit");

        double celCel = ((Double.parseDouble(jTextField1.getText()))
                - 32);
        jLabel7.setText(celCel * 0.55555555556 + " Celsius");

        double celReau = ((Double.parseDouble(jTextField1.getText()))
                - 32);
        jLabel10.setText(celReau * 0.4444444444444444 + " Réaumur");

        double celRan = ((Double.parseDouble(jTextField1.getText()))
                + 459.67);
        jLabel11.setText(celRan + " Rankine");

        double faKel = ((Double.parseDouble(jTextField1.getText()))
                + 459.67);
        jLabel9.setText(faKel * 0.55555555556 + " Kelvin");
    }//GEN-LAST:event_jRadioButton2ActionPerformed

    private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton3ActionPerformed
        double kelFaren = ((Double.parseDouble(jTextField1.getText()))
                * 1.8 - 459.67);
        jLabel8.setText(kelFaren + " Fahrenheit");

        double kelCel = ((Double.parseDouble(jTextField1.getText()))
                - 273.15);
        jLabel7.setText(kelCel + " Celsius");

        double kelReau = ((Double.parseDouble(jTextField1.getText()))
                - 273.15);
        jLabel10.setText(kelReau * 0.8 + " Réaumur");

        double kelRan = ((Double.parseDouble(jTextField1.getText()))
                * 1.8);
        jLabel11.setText(kelRan + " Rankine");

        double kelKel = ((Double.parseDouble(jTextField1.getText())));
        jLabel9.setText(kelKel + " Kelvin");
    }//GEN-LAST:event_jRadioButton3ActionPerformed

    private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton4ActionPerformed
        double ranFaren = ((Double.parseDouble(jTextField1.getText()))
                - 459.67);
        jLabel8.setText(ranFaren + " Fahrenheit");

        double ranCel = ((Double.parseDouble(jTextField1.getText()))
                - 491.67);
        jLabel7.setText(ranCel * 0.55555555556 + " Celsius");

        double ranReau = ((Double.parseDouble(jTextField1.getText()))
                - 491.67);
        jLabel10.setText(ranReau * 0.4444444444444444 + " Réaumur");

        double ranRan = ((Double.parseDouble(jTextField1.getText())));
        jLabel11.setText(ranRan + " Rankine");

        double ranKel = ((Double.parseDouble(jTextField1.getText()))
                * 0.55555555556);
        jLabel9.setText(ranKel + " Kelvin");
    }//GEN-LAST:event_jRadioButton4ActionPerformed

    private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton5ActionPerformed
        double reaFaren = ((Double.parseDouble(jTextField1.getText()))
                * 2.25 + 32);
        jLabel8.setText(reaFaren + " Fahrenheit");

        double reaCel = ((Double.parseDouble(jTextField1.getText()))
                *1.25);
        jLabel7.setText(reaCel + " Celsius");

        double reaReau = ((Double.parseDouble(jTextField1.getText()))
                );
        jLabel10.setText(reaReau + " Réaumur");

        double reaRan = ((Double.parseDouble(jTextField1.getText()))
                *2.25 + 491.67);
        jLabel11.setText(reaRan + " Rankine");

        double reaKel = ((Double.parseDouble(jTextField1.getText()))
                * 1.25 + 273.15);
        jLabel9.setText(reaKel + " Kelvin");
    }//GEN-LAST:event_jRadioButton5ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton5;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
}
